import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
    selector: 'op-dialog',
    templateUrl: './dev-extreme-dialog.component.html'
})
export class DevExtremeDialogComponent implements OnInit {
    @Output() closeDialog = new EventEmitter<boolean>();
    @Input() isShowTitle: boolean;
    @Input() dragEnabled: boolean;
    @Input() closeOnOutsideClick: boolean;
    @Input() visible: boolean;
    @Input() titleCenter: boolean;
    @Input() title: string;
    @Input() width: number;
    @Input() height: number;

    constructor() {
    }

    ngOnInit(): void {
        this.initializeProperties();
    }

    visibleChange(event: boolean): void {
        if (!event) {
            this.closeDialog.emit();
        }
    }

    protected initializeProperties(): void {
        this.isShowTitle = this.isShowTitle || false;
        this.dragEnabled = this.dragEnabled || false;
        this.closeOnOutsideClick = this.closeOnOutsideClick || true;
        this.title = this.title || null;
        this.width = this.width || null;
        this.height = this.height || null;
    }
}